package com.wyd.System.Controller;


import com.wyd.System.Bean.Grade;
import com.wyd.System.Service.GradeService;
import com.wyd.handler.BusinessException;
import com.wyd.response.Result;
import com.wyd.response.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 文永达
 * @since 2020-12-06
 */
@Api(value = "年级")
@RestController
@RequestMapping("/System/grade")
public class GradeController {

    @Autowired
    private GradeService gradeService;

    @ApiOperation(value = "查询年级",notes = "")
    @GetMapping("/findGrade")
    public Result findGrade(){
        List<Grade> grades = gradeService.findGrade();
        if(grades.size()==0){
            throw new BusinessException(ResultCode.GRADE_NOT_FOUND_EXCEPTION.getCode(),
                    ResultCode.GRADE_NOT_FOUND_EXCEPTION.getMessage());
        }
        return Result.ok().data("grades",grades);
    }

}

